{% extends 'admin/common/base.html' %}
{% block body %}

<body class="gray-bg">
    <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="role-form">
                    <div class="select-list">
                        <ul>
                            <li>
                                名称：<input type="text" name="name" />
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                        class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                        class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success {{check_perms('sys:setting:add')}}" onclick="$.operate.add()">
                    <i class="fa fa-plus"></i> 新增
                </a>
                <a class="btn btn-primary single disabled {{check_perms('sys:setting:edit')}}" onclick="$.operate.edit()">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled {{check_perms('sys:setting:remove')}}" onclick="$.operate.removeAll()">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning {{check_perms('sys:setting:export')}}" onclick="$.table.exportExcel()">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
</body>
{% endblock %}
{% block js %}
{{ super() }}
<script>
    var stype_datas = {{get_dict_data('sys_setting_stype') | tojson | safe}};
    var editFlag = "{{check_perms('sys:setting:edit')}}";
    var removeFlag = "{{check_perms('sys:setting:remove')}}";
    $(function () {
        var options = {
            url: "{{url_for('admin.sys.setting.list')}}",
            createUrl: "{{url_for('admin.sys.setting.add')}}",
            updateUrl: "{{url_for('admin.sys.setting.edit')}}?id={id}",
            removeUrl: "{{url_for('admin.sys.setting.remove')}}",
            exportUrl: "{{url_for('admin.sys.setting.export')}}",
            modalName: "系统参数",
            columns: [
            {
                checkbox: true
            },
            {
                field: 'id',
                title: 'ID',
                visible: false
            },
            {
                field: 'sname',
                title: '参数名称'
            },
            {
                field: 'skey',
                title: '参数键名'
            },
            {
                field: 'col_type',
                title: '输入类型',
                formatter: function(value, row, index) {
                    if(value == 'file'){
                        return '图片/文件'
                    }
                    if(value == 'richtext'){
                        return '富文本'
                    }
                    return '文本'
                }
            },
            {
                field: 'svalue',
                title: '参数键值',
                formatter: function(value, row, index) {
                    if(value.indexOf('<') > -1) {
                        return $.table.tooltip(value.replaceAll('<', '~'), 10, "open")
                    }
                    return $.table.tooltip(value, 10, "open");
                }
            },
            {
                field: 'remark',
                title: '备注',
                align: 'center',
                formatter: function(value, row, index) {
                    return $.table.tooltip(value, 10, "open");
                }
            },
            {
                title: '操作',
                align: 'center',
                formatter: function (value, row, index) {
                    var actions = [];
                    actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                    actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a> ');
                    return actions.join('');
                }
            }]
        };
        $.table.init(options);
    });

</script>
{% endblock %}